package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

/**
 * DEUtil 工具类测试
 */
public class JDBCDemo4 {
    public static void main(String[] args) throws SQLException {
        Connection connection;
        try {//创建数据库连接对象[利用工具类]
            connection = DBUtil.getConnection();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        Statement statement = connection.createStatement();
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String userName = scan.nextLine();

        int i = statement.executeUpdate("DELETE FROM userinfo WHERE userName='" + userName + "'");
        if (i > 0) {
            System.out.println("注销成功！");
        } else {
            System.out.println("注销失败");
        }
        connection.close();

    }
}
